package fanshe;

import java.lang.reflect.Field;
import java.util.*;

import cn.shcool.entity.Subject;

public class ClsTest {

	public static Object createObj(Class c) throws Exception {
		return c.newInstance();

	}

	public static void main(String[] args) throws Exception {
//		Class c = Vector.class;
//
//		Vector v = (Vector) c.newInstance();
		Vector v1 = (Vector) createObj(Vector.class);
		LinkedList l = (LinkedList) createObj(LinkedList.class);

		Subject s = (Subject) createObj(Class.forName("cn.shcool.entity.Subject"));
		System.out.println(s);

		Field f = s.getClass().getDeclaredField("subjectname");
		f.setAccessible(true);
		// obj.subjectname="xxxx"
		f.set(s, "原子弹的维修与保养");
		System.out.println(s);
	}

}
